package com.kczd.jinlan.adapter.recycleviewadapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.TextView;

import com.kczd.jinlan.R;
import com.kczd.jinlan.model.Evaluate;

import java.util.ArrayList;
import java.util.List;

/**
 * 评价daapter
 * Created by Administrator on 2017/5/25.
 */

public class RecycleViewPingjiaAdapter extends RecyclerView.Adapter<RecycleViewPingjiaAdapter.ViewHolder>{


    private Context mContext;
    private List<Evaluate> dataList = new ArrayList<>();


    public void addAllData(List<Evaluate> dataList) {
        this.dataList.addAll(dataList);
        notifyDataSetChanged();
    }

    public void clearData() {
        this.dataList.clear();
    }

    public RecycleViewPingjiaAdapter(Context context) {
        mContext = context;
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

        public TextView text_title_list;
        public TextView text_data;
        public TextView text_am;
        public TextView text_comment;
        public ImageView id_image;
        public GridView noScrollgridview;


        public ViewHolder(View itemView) {
            super(itemView);
            text_title_list = (TextView) itemView.findViewById(R.id.text_title_list);
            text_data = (TextView) itemView.findViewById(R.id.text_data);
            text_am = (TextView) itemView.findViewById(R.id.text_am);
            text_comment = (TextView) itemView.findViewById(R.id.text_comment);
            id_image = (ImageView) itemView.findViewById(R.id.id_image);
            noScrollgridview= (GridView) itemView.findViewById(R.id.noScrollgridview);
        }
    }

    @Override
    public RecycleViewPingjiaAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.pingjia_item_recycleview, parent, false);
        return new RecycleViewPingjiaAdapter.ViewHolder(v);
    }


    @Override
    public void onBindViewHolder(RecycleViewPingjiaAdapter.ViewHolder holder, final int position) {

        holder.text_title_list.setText(dataList.get(position).getTitle_ev());
        holder.text_data.setText(dataList.get(position).getData_ev());
        holder.text_am.setText(dataList.get(position).getTime_ev());
        holder.text_comment.setText(dataList.get(position).getComment());
//        holder.id_image.setImageResource(dataList.get(position).getImage());

    }

    @Override
    public int getItemCount() {
        return dataList.size();
    }
}
